package com.aaa.service.impl;

import com.aaa.common.domain.RentOutContractInfo;
import com.aaa.common.result.Result;
import com.aaa.mapper.RentOutContractInfoUpdateMapper;
import com.aaa.service.RentOutContractInfoUpdateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 宋文森
 * @Date: 2021/02/03/16:23
 * @Description:
 */
@Service
public class RentOutContractInfoUpdateServiceImpl extends ServiceImpl<RentOutContractInfoUpdateMapper,RentOutContractInfo> implements RentOutContractInfoUpdateService {

    @Autowired
    private RentOutContractInfoUpdateMapper rentOutContractInfoUpdateMapper;


    public Result rentOutContractListOne(Integer id){
        RentOutContractInfo rentOutContractInfo = rentOutContractInfoUpdateMapper.selectById(id);
        if (rentOutContractInfo!=null){
            return Result.success(rentOutContractInfo);
        }
        return Result.error("根据id查询租出合同失败");
    }

    public Result rentOutContractUpdate(RentOutContractInfo rentOutContractInfo) {
        int i = rentOutContractInfoUpdateMapper.updateById(rentOutContractInfo);
        if (i>0){
            return Result.success("资产出租合同修改成功");
        }
        return Result.error("资产出租合同修改失败");
    }

    public Result rentOutContractDelete(int id) {
        int i = rentOutContractInfoUpdateMapper.deleteById(id);
        if (i>0){
            return Result.success("资产出租合同删除成功!");
        }
        return Result.error("资产出租合同删除失败!");
    }
}
